unit uMedico;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uPai, DB, StdCtrls, DBCtrls, Buttons, ExtCtrls, ComCtrls, Mask,
  FacDbEdit;

type
  TfMedico = class(TfPai)
    Label1: TLabel;
    FacDBEdit1: TFacDBEdit;
    FacDBEdit2: TFacDBEdit;
    Label2: TLabel;
    FacDBEdit3: TFacDBEdit;
    Label3: TLabel;
    FacDBEdit4: TFacDBEdit;
    Label4: TLabel;
    FacDBEdit5: TFacDBEdit;
    Label5: TLabel;
    Panel4: TPanel;
    Panel1: TPanel;
    Label10: TLabel;
    Label18: TLabel;
    FacDBEdit15: TFacDBEdit;
    FacDBEdit13: TFacDBEdit;
    FacDBEdit6: TFacDBEdit;
    Label6: TLabel;
    FacDBEdit7: TFacDBEdit;
    Label7: TLabel;
    FacDBEdit8: TFacDBEdit;
    Label8: TLabel;
    DBComboBox3: TDBComboBox;
    Label15: TLabel;
    FacDBEdit12: TFacDBEdit;
    Label16: TLabel;
    FacDBEdit9: TFacDBEdit;
    Label9: TLabel;
    FacDBEdit10: TFacDBEdit;
    Label11: TLabel;
    procedure FormShow(Sender: TObject);
    procedure btnIncluirClick(Sender: TObject);
    procedure FacDBEdit10Exit(Sender: TObject);
    procedure btnProcurarClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fMedico: TfMedico;

implementation

uses UDM, uProcurar;

{$R *.dfm}

procedure TfMedico.FormShow(Sender: TObject);
begin
  inherited;
  btnIncluir.SetFocus;
end;

procedure TfMedico.btnIncluirClick(Sender: TObject);
begin
  inherited;
  FacDBEdit2.SetFocus;
end;

procedure TfMedico.FacDBEdit10Exit(Sender: TObject);
begin
  inherited;
  if dm.cds_medico.State in [dsInsert, dsEdit] then
    btngravar.SetFocus
  else
    btnSair.SetFocus;
end;

procedure TfMedico.btnProcurarClick(Sender: TObject);
begin
  inherited;

  fProcurar:=TfProcurar.Create(self,dm.proc_medico);
  try
   fProcurar.BtnProcurar.Click;
   fProcurar.EvDBFind1.DataField := 'NOME_MEDICO';
   if fProcurar.ShowModal=mrOk then
    begin
    Dm.cds_medico.Close;
    Dm.cds_medico.Params[0].AsInteger:=Dm.proc_medicoCOD_MEDICO.AsInteger;
    Dm.cds_medico.Open;
    end;
   finally
    dm.proc_medico.Close;
    fProcurar.Free;
   end;
    

end;

end.
